package com.fable.sp.core.widget;

import java.util.Locale;

/**
 * .
 *
 * @author stormning on 16/7/30.
 */
public class WidgetMode {
    public final static WidgetMode VIEW = new WidgetMode("view");

    public final static WidgetMode EDIT = new WidgetMode("edit");

    private String _name;

    public WidgetMode(String name) {
        if (name == null) {
            throw new IllegalArgumentException("WidgetMode name can not be NULL");
        }
        _name = name.toLowerCase(Locale.CHINA);
    }

    public String toString() {
        return _name;
    }

    public int hashCode() {
        return _name.hashCode();
    }

    public boolean equals(Object object) {
        if (object instanceof WidgetMode) {
            return _name.equals(((WidgetMode) object)._name);
        } else {
            return false;
        }
    }
}
